//
//  MKTalentPoolCell.swift
//  MOKOAnnounce
//
//  Created by 曹相召 on 2017/7/11.
//  Copyright © 2017年 cc.moko. All rights reserved.
//

import UIKit

class MKTalentPoolCell: UICollectionViewCell {
    
    var icon:UIImageView!
    var tip:UILabel!
    var searchedModel:MKMtbSearchedModel?{
        didSet{
            if searchedModel?.nickname != nil{
                self.tip.text = searchedModel?.nickname
            }
            if searchedModel?.photo != nil{
                self.icon.setImage(urlStr: (searchedModel?.photo)!, placeholderStr: "temp")
            }
            self.setNeedsLayout()
        }
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.layer.cornerRadius = 5
        self.clipsToBounds = true
        
        self.icon = UIImageView.init()
//        self.icon.backgroundColor = UIColor.randomColor()
//        self.icon.image = UIImage.init(named: "temp")
        self.icon.contentMode = .scaleAspectFill
       
        self.contentView.addSubview(self.icon)
        
        self.tip = UILabel.label(fontSize: 16, textColor: UIColor.white)
        self.tip.text = "曹操"
        self.tip.backgroundColor = UIColor.black.withAlphaComponent(0.5)
        self.tip.lineBreakMode = .byTruncatingTail
        self.tip.textAlignment = .center
        self.contentView.addSubview(self.tip)
    }
    override func layoutSubviews() {
        super.layoutSubviews()
        self.icon.frame = self.contentView.bounds
        self.tip.frame = CGRect.init(x: 0, y: self.contentView.height - 32, width: self.contentView.width, height: 32)
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
